package kz.kstu.aecdemo.business.util;

import java.math.BigInteger;

/**
 * @author Filipp_Stankevich
 *         created: 11.09.11 18:00
 */
public class StringUtil {

    public static final String EMPTY_STRING = "";

    public static final String SPACE = " ";

    public static final String DOT = ".";
    private static final String GETTER_PREFIX = "get";

    public static final String SEMICOLON = ";";

    public static boolean isNumber(String number) {
        try {
            new BigInteger(number);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }

    public static boolean isEmptyString(String value) {
        return value == null || value.length() == 0;
    }

    public static String byteArrayToHexString(byte[] data) {
        StringBuilder buffer = new StringBuilder();
        for (byte element : data) {
            buffer.append(String.format("%02X", element));
            buffer.append(SPACE);
        }
        return buffer.toString();
    }

    public static String getGetterByProperty(String property) {
        return GETTER_PREFIX + property.substring(0, 1).toUpperCase() + property.substring(1);
    }
}
